import 'package:FiduMart/generated/json/base/json_convert_content.dart';
import 'package:FiduMart/core/network/model/currencyrank_list_entity.dart';

CurrencyrankListEntity $CurrencyrankListEntityFromJson(
    Map<String, dynamic> json) {
  final CurrencyrankListEntity currencyrankListEntity = CurrencyrankListEntity();
  final int? lastId = jsonConvert.convert<int>(json['last_id']);
  if (lastId != null) {
    currencyrankListEntity.lastId = lastId;
  }
  final List<CurrencyrankListList>? list = (json['list'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<CurrencyrankListList>(e) as CurrencyrankListList)
      .toList();
  if (list != null) {
    currencyrankListEntity.list = list;
  }
  final String? pages = jsonConvert.convert<String>(json['pages']);
  if (pages != null) {
    currencyrankListEntity.pages = pages;
  }
  final int? totalPage = jsonConvert.convert<int>(json['total_page']);
  if (totalPage != null) {
    currencyrankListEntity.totalPage = totalPage;
  }
  final int? totalCount = jsonConvert.convert<int>(json['total_count']);
  if (totalCount != null) {
    currencyrankListEntity.totalCount = totalCount;
  }
  final int? totalCountForRank = jsonConvert.convert<int>(
      json['total_count_for_rank']);
  if (totalCountForRank != null) {
    currencyrankListEntity.totalCountForRank = totalCountForRank;
  }
  final int? totalCountForNorank = jsonConvert.convert<int>(
      json['total_count_for_norank']);
  if (totalCountForNorank != null) {
    currencyrankListEntity.totalCountForNorank = totalCountForNorank;
  }
  final int? totalPageForRank = jsonConvert.convert<int>(
      json['total_page_for_rank']);
  if (totalPageForRank != null) {
    currencyrankListEntity.totalPageForRank = totalPageForRank;
  }
  final int? totalPageForNorank = jsonConvert.convert<int>(
      json['total_page_for_norank']);
  if (totalPageForNorank != null) {
    currencyrankListEntity.totalPageForNorank = totalPageForNorank;
  }
  return currencyrankListEntity;
}

Map<String, dynamic> $CurrencyrankListEntityToJson(
    CurrencyrankListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['last_id'] = entity.lastId;
  data['list'] = entity.list?.map((v) => v.toJson()).toList();
  data['pages'] = entity.pages;
  data['total_page'] = entity.totalPage;
  data['total_count'] = entity.totalCount;
  data['total_count_for_rank'] = entity.totalCountForRank;
  data['total_count_for_norank'] = entity.totalCountForNorank;
  data['total_page_for_rank'] = entity.totalPageForRank;
  data['total_page_for_norank'] = entity.totalPageForNorank;
  return data;
}

extension CurrencyrankListEntityExt on CurrencyrankListEntity {
  CurrencyrankListEntity copyWith({
    int? lastId,
    List<CurrencyrankListList>? list,
    String? pages,
    int? totalPage,
    int? totalCount,
    int? totalCountForRank,
    int? totalCountForNorank,
    int? totalPageForRank,
    int? totalPageForNorank,
  }) {
    return CurrencyrankListEntity()
      ..lastId = lastId ?? this.lastId
      ..list = list ?? this.list
      ..pages = pages ?? this.pages
      ..totalPage = totalPage ?? this.totalPage
      ..totalCount = totalCount ?? this.totalCount
      ..totalCountForRank = totalCountForRank ?? this.totalCountForRank
      ..totalCountForNorank = totalCountForNorank ?? this.totalCountForNorank
      ..totalPageForRank = totalPageForRank ?? this.totalPageForRank
      ..totalPageForNorank = totalPageForNorank ?? this.totalPageForNorank;
  }
}

CurrencyrankListList $CurrencyrankListListFromJson(Map<String, dynamic> json) {
  final CurrencyrankListList currencyrankListList = CurrencyrankListList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    currencyrankListList.id = id;
  }
  final int? currencyId = jsonConvert.convert<int>(json['currency_id']);
  if (currencyId != null) {
    currencyrankListList.currencyId = currencyId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    currencyrankListList.name = name;
  }
  final String? symbol = jsonConvert.convert<String>(json['symbol']);
  if (symbol != null) {
    currencyrankListList.symbol = symbol;
  }
  final int? rank = jsonConvert.convert<int>(json['rank']);
  if (rank != null) {
    currencyrankListList.rank = rank;
  }
  final String? logo = jsonConvert.convert<String>(json['logo']);
  if (logo != null) {
    currencyrankListList.logo = logo;
  }
  final int? marketId = jsonConvert.convert<int>(json['market_id']);
  if (marketId != null) {
    currencyrankListList.marketId = marketId;
  }
  final String? marketName = jsonConvert.convert<String>(json['market_name']);
  if (marketName != null) {
    currencyrankListList.marketName = marketName;
  }
  final String? comId = jsonConvert.convert<String>(json['com_id']);
  if (comId != null) {
    currencyrankListList.comId = comId;
  }
  final String? pair = jsonConvert.convert<String>(json['pair']);
  if (pair != null) {
    currencyrankListList.pair = pair;
  }
  final String? currency = jsonConvert.convert<String>(json['currency']);
  if (currency != null) {
    currencyrankListList.currency = currency;
  }
  final String? anchor = jsonConvert.convert<String>(json['anchor']);
  if (anchor != null) {
    currencyrankListList.anchor = anchor;
  }
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    currencyrankListList.price = price;
  }
  final String? priceCny = jsonConvert.convert<String>(json['price_cny']);
  if (priceCny != null) {
    currencyrankListList.priceCny = priceCny;
  }
  final String? priceUsd = jsonConvert.convert<String>(json['price_usd']);
  if (priceUsd != null) {
    currencyrankListList.priceUsd = priceUsd;
  }
  final double? volume24h = jsonConvert.convert<double>(json['volume_24h']);
  if (volume24h != null) {
    currencyrankListList.volume24h = volume24h;
  }
  final String? volume24hUsd = jsonConvert.convert<String>(
      json['volume_24h_usd']);
  if (volume24hUsd != null) {
    currencyrankListList.volume24hUsd = volume24hUsd;
  }
  final int? volume24hFrom = jsonConvert.convert<int>(json['volume_24h_from']);
  if (volume24hFrom != null) {
    currencyrankListList.volume24hFrom = volume24hFrom;
  }
  final dynamic volume24hTo = json['volume_24h_to'];
  if (volume24hTo != null) {
    currencyrankListList.volume24hTo = volume24hTo;
  }
  final double? percentChangeUtc0 = jsonConvert.convert<double>(
      json['percent_change_utc0']);
  if (percentChangeUtc0 != null) {
    currencyrankListList.percentChangeUtc0 = percentChangeUtc0;
  }
  final double? percentChangeUtc8 = jsonConvert.convert<double>(
      json['percent_change_utc8']);
  if (percentChangeUtc8 != null) {
    currencyrankListList.percentChangeUtc8 = percentChangeUtc8;
  }
  final double? percentChange24h = jsonConvert.convert<double>(
      json['percent_change_24h']);
  if (percentChange24h != null) {
    currencyrankListList.percentChange24h = percentChange24h;
  }
  final double? percentChange7d = jsonConvert.convert<double>(
      json['percent_change_7d']);
  if (percentChange7d != null) {
    currencyrankListList.percentChange7d = percentChange7d;
  }
  final int? priceUpdatedAt = jsonConvert.convert<int>(
      json['price_updated_at']);
  if (priceUpdatedAt != null) {
    currencyrankListList.priceUpdatedAt = priceUpdatedAt;
  }
  final dynamic tvSymbol = json['tv_symbol'];
  if (tvSymbol != null) {
    currencyrankListList.tvSymbol = tvSymbol;
  }
  final int? ccKline = jsonConvert.convert<int>(json['cc_kline']);
  if (ccKline != null) {
    currencyrankListList.ccKline = ccKline;
  }
  final int? klineEnabled = jsonConvert.convert<int>(json['kline_enabled']);
  if (klineEnabled != null) {
    currencyrankListList.klineEnabled = klineEnabled;
  }
  final String? klineSource = jsonConvert.convert<String>(json['kline_source']);
  if (klineSource != null) {
    currencyrankListList.klineSource = klineSource;
  }
  final String? marketCapUsd = jsonConvert.convert<String>(
      json['market_cap_usd']);
  if (marketCapUsd != null) {
    currencyrankListList.marketCapUsd = marketCapUsd;
  }
  final String? alias = jsonConvert.convert<String>(json['alias']);
  if (alias != null) {
    currencyrankListList.alias = alias;
  }
  final String? marketAlias = jsonConvert.convert<String>(json['market_alias']);
  if (marketAlias != null) {
    currencyrankListList.marketAlias = marketAlias;
  }
  final int? availableSupply = jsonConvert.convert<int>(
      json['available_supply']);
  if (availableSupply != null) {
    currencyrankListList.availableSupply = availableSupply;
  }
  final int? maxSupply = jsonConvert.convert<int>(json['max_supply']);
  if (maxSupply != null) {
    currencyrankListList.maxSupply = maxSupply;
  }
  final int? totalSupply = jsonConvert.convert<int>(json['total_supply']);
  if (totalSupply != null) {
    currencyrankListList.totalSupply = totalSupply;
  }
  final int? isNew = jsonConvert.convert<int>(json['is_new']);
  if (isNew != null) {
    currencyrankListList.isNew = isNew;
  }
  final int? enabled = jsonConvert.convert<int>(json['enabled']);
  if (enabled != null) {
    currencyrankListList.enabled = enabled;
  }
  final int? canTradeInOkx = jsonConvert.convert<int>(json['can_trade_in_okx']);
  if (canTradeInOkx != null) {
    currencyrankListList.canTradeInOkx = canTradeInOkx;
  }
  final int? isLeadingCurrency = jsonConvert.convert<int>(
      json['is_leading_currency']);
  if (isLeadingCurrency != null) {
    currencyrankListList.isLeadingCurrency = isLeadingCurrency;
  }
  final String? priceDisplayCny = jsonConvert.convert<String>(
      json['price_display_cny']);
  if (priceDisplayCny != null) {
    currencyrankListList.priceDisplayCny = priceDisplayCny;
  }
  final String? marketCapDisplay = jsonConvert.convert<String>(
      json['market_cap_display']);
  if (marketCapDisplay != null) {
    currencyrankListList.marketCapDisplay = marketCapDisplay;
  }
  final String? marketCapDisplayCny = jsonConvert.convert<String>(
      json['market_cap_display_cny']);
  if (marketCapDisplayCny != null) {
    currencyrankListList.marketCapDisplayCny = marketCapDisplayCny;
  }
  final String? percentChangeDisplay = jsonConvert.convert<String>(
      json['percent_change_display']);
  if (percentChangeDisplay != null) {
    currencyrankListList.percentChangeDisplay = percentChangeDisplay;
  }
  final bool? isFavorite = jsonConvert.convert<bool>(json['is_favorite']);
  if (isFavorite != null) {
    currencyrankListList.isFavorite = isFavorite;
  }
  final int? sevenDay = jsonConvert.convert<int>(json['seven_day']);
  if (sevenDay != null) {
    currencyrankListList.sevenDay = sevenDay;
  }
  final String? turnoverRate = jsonConvert.convert<String>(
      json['turnover_rate']);
  if (turnoverRate != null) {
    currencyrankListList.turnoverRate = turnoverRate;
  }
  final String? turnoverRateRaw = jsonConvert.convert<String>(
      json['turnover_rate_raw']);
  if (turnoverRateRaw != null) {
    currencyrankListList.turnoverRateRaw = turnoverRateRaw;
  }
  final double? valueChangeKline7d = jsonConvert.convert<double>(
      json['value_change_kline_7d']);
  if (valueChangeKline7d != null) {
    currencyrankListList.valueChangeKline7d = valueChangeKline7d;
  }
  final List<dynamic>? kline = (json['kline'] as List<dynamic>?)?.map(
          (e) => e).toList();
  if (kline != null) {
    currencyrankListList.kline = kline;
  }
  final List<int>? lineData = (json['line_data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<int>(e) as int).toList();
  if (lineData != null) {
    currencyrankListList.lineData = lineData;
  }
  return currencyrankListList;
}

Map<String, dynamic> $CurrencyrankListListToJson(CurrencyrankListList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['currency_id'] = entity.currencyId;
  data['name'] = entity.name;
  data['symbol'] = entity.symbol;
  data['rank'] = entity.rank;
  data['logo'] = entity.logo;
  data['market_id'] = entity.marketId;
  data['market_name'] = entity.marketName;
  data['com_id'] = entity.comId;
  data['pair'] = entity.pair;
  data['currency'] = entity.currency;
  data['anchor'] = entity.anchor;
  data['price'] = entity.price;
  data['price_cny'] = entity.priceCny;
  data['price_usd'] = entity.priceUsd;
  data['volume_24h'] = entity.volume24h;
  data['volume_24h_usd'] = entity.volume24hUsd;
  data['volume_24h_from'] = entity.volume24hFrom;
  data['volume_24h_to'] = entity.volume24hTo;
  data['percent_change_utc0'] = entity.percentChangeUtc0;
  data['percent_change_utc8'] = entity.percentChangeUtc8;
  data['percent_change_24h'] = entity.percentChange24h;
  data['percent_change_7d'] = entity.percentChange7d;
  data['price_updated_at'] = entity.priceUpdatedAt;
  data['tv_symbol'] = entity.tvSymbol;
  data['cc_kline'] = entity.ccKline;
  data['kline_enabled'] = entity.klineEnabled;
  data['kline_source'] = entity.klineSource;
  data['market_cap_usd'] = entity.marketCapUsd;
  data['alias'] = entity.alias;
  data['market_alias'] = entity.marketAlias;
  data['available_supply'] = entity.availableSupply;
  data['max_supply'] = entity.maxSupply;
  data['total_supply'] = entity.totalSupply;
  data['is_new'] = entity.isNew;
  data['enabled'] = entity.enabled;
  data['can_trade_in_okx'] = entity.canTradeInOkx;
  data['is_leading_currency'] = entity.isLeadingCurrency;
  data['price_display_cny'] = entity.priceDisplayCny;
  data['market_cap_display'] = entity.marketCapDisplay;
  data['market_cap_display_cny'] = entity.marketCapDisplayCny;
  data['percent_change_display'] = entity.percentChangeDisplay;
  data['is_favorite'] = entity.isFavorite;
  data['seven_day'] = entity.sevenDay;
  data['turnover_rate'] = entity.turnoverRate;
  data['turnover_rate_raw'] = entity.turnoverRateRaw;
  data['value_change_kline_7d'] = entity.valueChangeKline7d;
  data['kline'] = entity.kline;
  data['line_data'] = entity.lineData;
  return data;
}

extension CurrencyrankListListExt on CurrencyrankListList {
  CurrencyrankListList copyWith({
    int? id,
    int? currencyId,
    String? name,
    String? symbol,
    int? rank,
    String? logo,
    int? marketId,
    String? marketName,
    String? comId,
    String? pair,
    String? currency,
    String? anchor,
    String? price,
    String? priceCny,
    String? priceUsd,
    double? volume24h,
    String? volume24hUsd,
    int? volume24hFrom,
    dynamic volume24hTo,
    double? percentChangeUtc0,
    double? percentChangeUtc8,
    double? percentChange24h,
    double? percentChange7d,
    int? priceUpdatedAt,
    dynamic tvSymbol,
    int? ccKline,
    int? klineEnabled,
    String? klineSource,
    String? marketCapUsd,
    String? alias,
    String? marketAlias,
    int? availableSupply,
    int? maxSupply,
    int? totalSupply,
    int? isNew,
    int? enabled,
    int? canTradeInOkx,
    int? isLeadingCurrency,
    String? priceDisplayCny,
    String? marketCapDisplay,
    String? marketCapDisplayCny,
    String? percentChangeDisplay,
    bool? isFavorite,
    int? sevenDay,
    String? turnoverRate,
    String? turnoverRateRaw,
    double? valueChangeKline7d,
    List<dynamic>? kline,
    List<int>? lineData,
  }) {
    return CurrencyrankListList()
      ..id = id ?? this.id
      ..currencyId = currencyId ?? this.currencyId
      ..name = name ?? this.name
      ..symbol = symbol ?? this.symbol
      ..rank = rank ?? this.rank
      ..logo = logo ?? this.logo
      ..marketId = marketId ?? this.marketId
      ..marketName = marketName ?? this.marketName
      ..comId = comId ?? this.comId
      ..pair = pair ?? this.pair
      ..currency = currency ?? this.currency
      ..anchor = anchor ?? this.anchor
      ..price = price ?? this.price
      ..priceCny = priceCny ?? this.priceCny
      ..priceUsd = priceUsd ?? this.priceUsd
      ..volume24h = volume24h ?? this.volume24h
      ..volume24hUsd = volume24hUsd ?? this.volume24hUsd
      ..volume24hFrom = volume24hFrom ?? this.volume24hFrom
      ..volume24hTo = volume24hTo ?? this.volume24hTo
      ..percentChangeUtc0 = percentChangeUtc0 ?? this.percentChangeUtc0
      ..percentChangeUtc8 = percentChangeUtc8 ?? this.percentChangeUtc8
      ..percentChange24h = percentChange24h ?? this.percentChange24h
      ..percentChange7d = percentChange7d ?? this.percentChange7d
      ..priceUpdatedAt = priceUpdatedAt ?? this.priceUpdatedAt
      ..tvSymbol = tvSymbol ?? this.tvSymbol
      ..ccKline = ccKline ?? this.ccKline
      ..klineEnabled = klineEnabled ?? this.klineEnabled
      ..klineSource = klineSource ?? this.klineSource
      ..marketCapUsd = marketCapUsd ?? this.marketCapUsd
      ..alias = alias ?? this.alias
      ..marketAlias = marketAlias ?? this.marketAlias
      ..availableSupply = availableSupply ?? this.availableSupply
      ..maxSupply = maxSupply ?? this.maxSupply
      ..totalSupply = totalSupply ?? this.totalSupply
      ..isNew = isNew ?? this.isNew
      ..enabled = enabled ?? this.enabled
      ..canTradeInOkx = canTradeInOkx ?? this.canTradeInOkx
      ..isLeadingCurrency = isLeadingCurrency ?? this.isLeadingCurrency
      ..priceDisplayCny = priceDisplayCny ?? this.priceDisplayCny
      ..marketCapDisplay = marketCapDisplay ?? this.marketCapDisplay
      ..marketCapDisplayCny = marketCapDisplayCny ?? this.marketCapDisplayCny
      ..percentChangeDisplay = percentChangeDisplay ?? this.percentChangeDisplay
      ..isFavorite = isFavorite ?? this.isFavorite
      ..sevenDay = sevenDay ?? this.sevenDay
      ..turnoverRate = turnoverRate ?? this.turnoverRate
      ..turnoverRateRaw = turnoverRateRaw ?? this.turnoverRateRaw
      ..valueChangeKline7d = valueChangeKline7d ?? this.valueChangeKline7d
      ..kline = kline ?? this.kline
      ..lineData = lineData ?? this.lineData;
  }
}